# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=dav1d
pkgver=0.7.1
pkgrel=0
pkgdesc="small and fast AV1 Decoder"
url="https://code.videolan.org/videolan/dav1d"
arch="all"
license="BSD-2-Clause"
makedepends="nasm meson"
subpackages="$pkgname-dev lib$pkgname:libs"
source="https://code.videolan.org/videolan/dav1d/-/archive/$pkgver/dav1d-$pkgver.tar.bz2
	fix-32-bit-build-with-pic-enabled.patch
	"

build() {
	case "$CARCH" in
		armhf*) meson_opts="-Denable_asm=false" ;;
		*) meson_opts="-Denable_asm=true" ;;
	esac

	meson \
		--prefix=/usr \
		--buildtype=plain \
		-Denable_tests=true \
		-Denable_tools=true \
		-Dfuzzing_engine=none \
		-Dtestdata_tests=false \
		$meson_opts \
		build
	ninja -C build
}

check() {
	ninja -C build test
}

package() {
	DESTDIR="$pkgdir" ninja -C build install
}

sha512sums="7db0f2eb5f6cbf2809ffb9ebaa18bf1331df00dc6e9d571380b2524143ce3bfdd2e7df1a31e82a52640e7ac81b2712127a395e857d061118845011a1e5fb4751  dav1d-0.7.1.tar.bz2
62f881d1234a98ecac7e5eeb3c6ce16331972008f74dcd31887855198d6292204e6ab236c38cb46337b22de489daffab59ac4ea1c3a1a12ec117a2bb41ddca19  fix-32-bit-build-with-pic-enabled.patch"
